package middleware

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

func AccessOrigin() gin.HandlerFunc {
	return func(context *gin.Context) {
		context.Header("Access-Control-Allow-Origin", "*")
		context.Header("Access-Control-Allow-Headers", "*")
		if context.Request.Method == "OPTIONS" {
			context.JSON(http.StatusOK, nil)
			context.Abort()
			return
		}
	}
}
